package com.geekhalo.schedule.v1;

import com.geekhalo.schedule.task.TaskConfig;
import com.geekhalo.schedule.task.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

@Service
public class SpringScheduleService {
    @Autowired
    private TaskService taskService;

//    @Scheduled(fixedDelay = 5 * 1000, initialDelay = 1000)
    public void runTask(){
        TaskConfig taskConfig = TaskConfig.builder()
                .name("Spring Default Schedule")
                .build();
        this.taskService.runTask(taskConfig);
    }
}
